<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>nth-last-child demo</title>
    <style>
        div {
            float: left;
        }

        span {
            color: blue;
        }
    </style>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
        // 引入 jQuery
    </script>
</head>
<body>

<div>
    <ul>
        <li>John</li>
        <li>Karl</li>
        <li>Adam</li>
    </ul>
</div>
<div>
    <ul>
        <li>Dan</li>
    </ul>
</div>
<div>
    <ul>
        <li>Dave</li>
        <li>Rick</li>
        <li>Timmy</li>
        <li>Gibson</li>
    </ul>
</div>
<script>
    $("ul li:nth-last-child(1)").append("<span> - 1nd to last!</span>");
    $(function () {
        $("div").css({"color": "red"});
    })
</script>

</body>
</html>